]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Add source actor without count label
authorCarlos Soriano <carlos.soriano89@gmail.com>
Fri, 14 Feb 2014 17:39:32 +0000 (18:39 +0100)
committerCarlos Soriano <carlos.soriano89@gmail.com>
Mon, 17 Feb 2014 12:22:39 +0000 (13:22 +0100)
Split the current implementation of SourceActor into
SourceActor and SourceActorWithLabel.
In this manner we can use source actors withouth count labels,
required in the screenShield to not clash with the count
text label.

https://bugzilla.gnome.org/show_bug.cgi?id=709275

js/ui/messageTray.js

index 53e838eb4ad2b79be110f4671147070eb7659357..68a22576d80a978fe7da7e71e9676d75f9663105 100644 (file)
@@ -1162,32 +1162,12 @@ const SourceActor = new Lang.Class({
         }));
         this._actorDestroyed = false;
 
-        this._counterLabel = new St.Label({ x_align: Clutter.ActorAlign.CENTER,
-                                            x_expand: true,
-                                            y_align: Clutter.ActorAlign.CENTER,
-                                            y_expand: true });
-
-        this._counterBin = new St.Bin({ style_class: 'summary-source-counter',
-                                        child: this._counterLabel,
-                                        layout_manager: new Clutter.BinLayout() });
-        this._counterBin.hide();
-
-        this._counterBin.connect('style-changed', Lang.bind(this, function() {
-            let themeNode = this._counterBin.get_theme_node();
-            this._counterBin.translation_x = themeNode.get_length('-shell-counter-overlap-x');
-            this._counterBin.translation_y = themeNode.get_length('-shell-counter-overlap-y');
-        }));
-
         this._iconBin = new St.Bin({ width: size,
                                      height: size,
                                      x_fill: true,
                                      y_fill: true });
 
         this.actor.add_actor(this._iconBin);
-        this.actor.add_actor(this._counterBin);
-
-        this._source.connect('count-updated', Lang.bind(this, this._updateCount));
-        this._updateCount();
 
         this._source.connect('icon-updated', Lang.bind(this, this._updateIcon));
         this._updateIcon();
@@ -1211,6 +1191,48 @@ const SourceActor = new Lang.Class({
     _allocate: function(actor, box, flags) {
         // the iconBin should fill our entire box
         this._iconBin.allocate(box, flags);
+    },
+
+    _updateIcon: function() {
+        if (this._actorDestroyed)
+            return;
+
+        if (!this._iconSet)
+            this._iconBin.child = this._source.createIcon(this._size);
+    }
+});
+
+const SourceActorWithLabel = new Lang.Class({
+    Name: 'SourceActorWithLabel',
+    Extends: SourceActor,
+
+    _init: function(source, size) {
+        this.parent(source, size);
+
+        this._counterLabel = new St.Label({ x_align: Clutter.ActorAlign.CENTER,
+                                            x_expand: true,
+                                            y_align: Clutter.ActorAlign.CENTER,
+                                            y_expand: true });
+
+        this._counterBin = new St.Bin({ style_class: 'summary-source-counter',
+                                        child: this._counterLabel,
+                                        layout_manager: new Clutter.BinLayout() });
+        this._counterBin.hide();
+
+        this._counterBin.connect('style-changed', Lang.bind(this, function() {
+            let themeNode = this._counterBin.get_theme_node();
+            this._counterBin.translation_x = themeNode.get_length('-shell-counter-overlap-x');
+            this._counterBin.translation_y = themeNode.get_length('-shell-counter-overlap-y');
+        }));
+
+        this.actor.add_actor(this._counterBin);
+
+        this._source.connect('count-updated', Lang.bind(this, this._updateCount));
+        this._updateCount();
+    },
+
+    _allocate: function(actor, box, flags) {
+        this.parent(actor, box, flags);
 
         let childBox = new Clutter.ActorBox();
 
@@ -1233,14 +1255,6 @@ const SourceActor = new Lang.Class({
         this._counterBin.allocate(childBox, flags);
     },
 
-    _updateIcon: function() {
-        if (this._actorDestroyed)
-            return;
-
-        if (!this._iconSet)
-            this._iconBin.child = this._source.createIcon(this._size);
-    },
-
     _updateCount: function() {
         if (this._actorDestroyed)
             return;
@@ -1353,7 +1367,7 @@ const Source = new Lang.Class({
         if (this._mainIcon)
             return;
 
-        this._mainIcon = new SourceActor(this, this.SOURCE_ICON_SIZE);
+        this._mainIcon = new SourceActorWithLabel(this, this.SOURCE_ICON_SIZE);
     },
 
     // Unlike createIcon, this always returns the same actor;